<template>
    <van-form @submit="dataFormSubmit">
        <van-cell-group class="container">
            <van-field v-model="dataForm.username" label="账号"  input-align="right"  disabled placeholder="请填写学校名称"/>
            <van-field v-model="dataForm.pwd" label="原密码" is-link input-align="right" placeholder="请输入原密码"/>
            <van-field v-model="dataForm.one_pwd" label="新密码" is-link input-align="right" type="password"  placeholder="请输入新密码"/>
            <van-field v-model="dataForm.two_pwd" label="确认密码" is-link input-align="right" type="password" placeholder="请输入确认密码"/>
        </van-cell-group>
        <div>
            <van-button block type="warning"
                        native-type="submit"
                        :disabled="confirmLoading"
                        :loading="confirmLoading"
                        loading-text="信息提交中..." class="confirm_btn">提交信息

            </van-button>
        </div>
    </van-form>
</template>

<script>
// @ is an alias to /src
import $api from "@/api/index"
import {mapGetters} from 'vuex'

import {
  getUserInfo,
} from "@/utils/auth";
export default {
  name: "editPassword",
  components: {},
  data() {
    return {
      show: false,
      confirmLoading: false,
      dataForm: {
        order_number: '',
        openid: '',
        city_id: '',
        country_id: '',
        province_id: '',
        school_name: '',
        one_pwd: '',
        two_pwd: '',
        contacts: '',
        phone: '',
        serve_code: ''
      },
      btnLoading: false,
      blockLoading: false,
      fieldValue: '',
      cascaderValue: '',
      tabIndex: 0,
      oneCityIndex: 0,
      cityOptions: [],
    };
  },
  created() {
    this.setUserInfo()
  },
  computed: {
    ...mapGetters(['info'])
  },
  methods: {
    setUserInfo(){
      const info=getUserInfo()
      console.log(info)
      this.dataForm = info
    },
    getCityList(id){
      return new Promise((resolve, reject) => {
        $api.baseInfo.getCityList({id}).then(res => {
          res.data.map(item => {
            item.text = item.name
            item.value = item.id
            if (this.tabIndex != 1) {
              item.children = []
            }
            return item
          })
          resolve(res.data)
        })
      })
    },
    // 表单提交
    dataFormSubmit() {
      $api.school.pwdEdit(this.dataForm).then(res => {
        this.$toast.success({
          message: res.message,
          duration: 1500,
          onClose: () => {
            this.$router.go(-1);
          },
        })

      }).finally(() => {
        this.confirmLoading = false
      })
    }
  }
};
</script>
<style lang="scss" scoped>
    ::v-deep {
        .container {
            margin-top: 10px;
            .van-cell {
                padding-left: 36px;
                padding-right: 36px;
                padding-top: 30px;
                padding-bottom: 30px;
                &:after {
                    left: 0;
                    right: 0;
                }
                .van-field__label {
                    font-size: 28px;
                    color: #555555;
                }

            }
        }
        .confirm_btn {
            width: 376px;
            height: 74px;
            background: linear-gradient(180deg, #FF9C70 0%, #FF804E 100%);
            border-radius: 10px;
            font-size: 28px;
            margin: 90px auto;
        }
    }
</style>
